/**************************************************************************************
* Component of simpleRTJ regression tests.
**************************************************************************************
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY,  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL RTJ COMPUTING BE LIABLE FOR ANY CLAIM, DAMAGES
* OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Created by:
*       RTJ Computing
**************************************************************************************/
public class TestBoolean
{
    public static boolean throwIt()
    {
        if (true)
        {
            throw new NullPointerException();
        }
        return true;
    }

    public static void test() throws Exception
    {
        int t1 = -1;
        int t2 = 1;
        int t3 = 2;
        int t4 = 2;
        boolean b = (t1 < t2);
        if (!b) throw new Exception("TBL1");
        b = (t3 > t2);
        if (!b) throw new Exception("TBL2");
        b = !b;
        if (b) throw new Exception("TBL3");
        b = (t3 == t4) && (t3 > t1);
        if (!b) throw new Exception("TBL4");
        b = (t3 != t4) || (t1 < t2);
        if (!b) throw new Exception("TBL5");

        b = (t3 == t2) ? false : true;
        if (!b) throw new Exception("TBL6");
        b = (t3 != t2) ? true : false;
        if (!b) throw new Exception("TBL7");

        //shortcut evaluation
        if ((t1 > t2) && (TestBoolean.throwIt())) throw new Exception("TBL8");
    }
}
